package com.zhaokuner.pm.ctrl;

import com.zhaokuner.pm.common.utils.MyDateUtils;
import com.zhaokuner.pm.common.utils.PinYinUtils;
import com.zhaokuner.pm.common.utils.RestClientUtil;
import com.zhaokuner.pm.model.NodeBO;
import com.zhaokuner.pm.model.enumeration.DeleteEnum;
import com.zhaokuner.pm.model.enumeration.NodeStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 类描述:测试
 *
 * @author 赵希坤 zhaoxikun
 * @date 2020/8/23 16:19
 */
@RestController
@RequestMapping("test")
public class TestCtrl {

    public String name(String name) {
        return name + " " + PinYinUtils.toSpell(name) + " " + PinYinUtils.toFirstSpell(name);
    }

    @RequestMapping("add")
    public Object add() {
        {
            NodeBO node = new NodeBO();
            node.setId("a");
            node.setPeriodical("6.29");
            node.setPeriodicalOrder(System.currentTimeMillis() + 0D);
            node.setRank(1D);
            node.setBizName("用户拉新业务线");
            node.setDemand("礼物服务添加优惠券");
            node.setTaskDetail("需求梳理&接口设计&文档编写");
            node.setDeveloper(name("赵希坤"));
            node.setEnemy(name("徐莹"));
            node.setLeader(name("陈雪峰"));
            node.setPowerful(name("吴小凤"));
            node.setManHour(8);
            node.setStartTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).minusDays(1)));
            node.setEndTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MAX).minusDays(1)));
            node.setStatus(NodeStatusEnum.NOT_PROJECT.getCode());
            node.setDeleteFlag(DeleteEnum.USABLE.getCode());
            RestClientUtil.create(node.getId(), node);
        }
        {
            NodeBO node = new NodeBO();
            node.setId("b");
            node.setPeriodical("6.29");
            node.setPeriodicalOrder(System.currentTimeMillis() + 0D);
            node.setRank(2D);
            node.setBizName("用户拉新业务线");
            node.setDemand("礼物服务添加优惠券");
            node.setTaskDetail("授权全部课程及缓存处理");
            node.setDeveloper(name("赵希坤"));
            node.setEnemy(name("徐莹"));
            node.setLeader(name("陈雪峰"));
            node.setPowerful(name("吴小凤"));
            node.setManHour(8);
            node.setStartTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).minusDays(1)));
            node.setEndTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MAX).minusDays(1)));
            node.setStatus(NodeStatusEnum.NOT_PROJECT.getCode());
            node.setDeleteFlag(DeleteEnum.USABLE.getCode());
            RestClientUtil.create(node.getId(), node);
        }
        {
            NodeBO node = new NodeBO();
            node.setId("c");
            node.setPeriodical("6.29");
            node.setPeriodicalOrder(System.currentTimeMillis() + 1D);
            node.setRank(3D);
            node.setBizName("用户激活业务线");
            node.setDemand("推送系统推送数据");
            node.setTaskDetail("需求梳理&接口设计&文档编写");
            node.setDeveloper(name("赵希坤"));
            node.setEnemy(name("徐莹"));
            node.setLeader(name("陈雪峰"));
            node.setPowerful(name("吴小凤"));
            node.setManHour(8);
            node.setStartTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).minusDays(1)));
            node.setEndTime(MyDateUtils.getTimestamp(LocalDateTime.of(LocalDate.now(), LocalTime.MAX).minusDays(1)));
            node.setStatus(NodeStatusEnum.NOT_PROJECT.getCode());
            node.setDeleteFlag(DeleteEnum.USABLE.getCode());
            RestClientUtil.create(node.getId(), node);
        }
        return "ok";
    }

}
